package com.draemoncode.weixindb;

import groovy.lang.Binding;
import groovy.lang.GroovyShell;

/**
 * Created by Administrator on 2017/4/19.
 */
public class GroovyShellExample {

    public static void main(String args[]) {

        Binding binding = new Binding();

        binding.setVariable("x", 10);

        binding.setVariable("language", "Groovy");

        GroovyShell shell = new GroovyShell(binding);

        Object value = shell.evaluate("println\"Welcome to $language\"; y = x * 2; z = x * 3; return x; ");

        System.out.println(value);

        System.out.println(binding.getVariable("y"));

        System.out.println(binding.getVariable("z"));
    }

}